package me.atbar.moonlib.builder.book;

import lombok.Getter;
import me.atbar.moonlib.builder.ItemBuilder;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;

/**
 * @author Administrator
 */
public class BookBuilder {

    @Getter
    private final String title;
    @Getter
    private final String author;
    @Getter
    private final ItemStack book;
    @Getter
    private final BookMeta bookMeta;

    public BookBuilder(String title, String author) {
        this.title = title;
        this.author = author;
        this.book = new ItemBuilder(Material.WRITTEN_BOOK).build();
        this.bookMeta = (BookMeta) this.book.getItemMeta();
        bookMeta.setTitle(title);
        bookMeta.setAuthor(author);
    }

    public BookBuilder addCommonPage(String... texts) {
        bookMeta.addPage(texts);
        return this;
    }

    public ItemStack build() {
        book.setItemMeta(bookMeta);
        return book;
    }

}
